<template>
	<view class="pay">
		<view class="pay-content">
			<view class="pay-price">
				<view>支付金额</view>
				<view class="pay-prices">¥{{price}}</view>
			</view>
			<view class="pay-method">
					<radio-group @change="chan">
						<label class="type-item" v-for="(item,index) in addpadding" :key="index">
							<view class="type-Text">
								<view class="icon-weixinzhifus"><image :src="item.img" mode=""></image></view>
								<view class="type-Name"><text>{{item.text}}</text><view v-if="index>=0">{{item.name}}</view></view>
							</view>
							<view>
								<radio :value="item.value+''" :checked="index==activeRadio" v-if="index<=0||index>=2"/>
								<radio disabled='true' v-if="index==1"/>
							</view>
						</label>
					</radio-group>
			</view>
			<view class="pay-submit" @click="submit()">
				<text>确认支付</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				activeRadio:"",
				price:"",
				data:"",
				Token:"",
				Checked: false, //是否全选
				allChecked: false, //是否全选
				addpadding:[
					{img:"../../static/icon_p8a64ra7t2/weixinzhifu.png",text:'微信支付',name:'推荐使用微信支付',value:0},
					{img:"../../static/icon_p8a64ra7t2/zhifubaox-.png",text:'支付宝（敬请期待）',value:1},
					{img:"../../static/icon_p8a64ra7t2/xianxiazhifu.png",text:'线下支付（到付）',value:2}
				]
			}
		},
		onLoad(e) {
			this.Token = uni.getStorageSync('Token')
			console.log(e)
			this.price=e.price
			this.data=e.data
		},
		methods:{
			chan(e){
							this.activeRadio = e.detail.value;
							console.log(this.activeRadio);
						},
			submit(){
				console.log(this.data)
				if(this.activeRadio==2){
					uni.request({
						url: this.$C.webUrl + `m.api?_gp=order&_mt=offlinePrepay&orderNo=${this.data}`,
						header: {
							'accessToken': this.Token
						},
						success: (res) => {
							console.log(res)
							 let timestamp=res.data.timestamp
							if(res.data.errmsg=="成功"){
								uni.navigateTo({
									url:`./success?data=${this.data}&times=${timestamp}`
								})
							}
						}
					})
				}
			}
		}
	}
</script>

<style>
	.pay{
		width: 100%;
	}
	.pay-submit text{
		font-size: 16px;
		    color: #fff;
			margin: auto;
	}
	.pay-submit{
		    width: 315px;
		    height: 40px;
		    margin: 40px auto 15px;
		    font-size: 16px;
			display: flex;
		    color: #fff;
		    background-color: #fa436a;
		    border-radius: 5px;
		    box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
	}
	.type-Name text{
		font-size: 32upx !important;
		    color: #303133;
	}
	.type-Name{
		font-size: 24upx;
		    color: #909399;
	}
	.icon-weixinzhifu image{
		width: 50upx;
		height: 50upx;
	
	}
	.icon-weixinzhifus image{
		width: 50upx;
		height: 50upx;
	
	}
	.icon-weixinzhifus{
		margin-right: 20upx;
	}
	.icon-weixinzhifu{
		margin-right: 20upx;
	}
	.type-Text{
		display: flex;
	}
	.type-item{
		height: 60px;
		    display: flex;
		    justify-content: space-between;
		    align-items: center;
		    padding-right: 30px;
		    font-size: 15px;
		    position: relative;
			border-bottom: 1px solid  #000000;
	}
	.pay-method{
		margin-top: 10px;
		    background-color: #fff;
		    padding-left: 30px;
	}
	.pay-content{
		display: block;
		  box-sizing: border-box;
		    width: 100%;
	}
	.pay-prices{
		font-size: 50upx !important;
		color: #000000 !important;
		margin: 10upx 0px;
	}
	.pay-price view{
		text-align: center;
		font-size: 30upx;
		color: #909399;
	}
	.pay-price{
		width: 100%;
		padding: 100upx 0px;
		
	}
</style>

<!-- <template>
 	<view>
 		<radio-group @change="chan">	
 			<label v-for="item in radioGroup" :key="item">
 				<radio :value="item" :checked="item==activeRadio" />{{item}}
 			</label>
 		</radio-group>
 	</view>
 </template>
 <script>
 	export default{
 		data(){
 			return{
 				activeRadio:'', //存的是选中的value值
 				radioGroup:['苹果','香蕉','梨','西红柿','西瓜']
 			}
 		},
 		methods:{
 			chan(e){
 				this.activeRadio = e.detail.value;
 				console.log(this.activeRadio);
 			}
 		}
 	}
 </script> -->